function getUrlParam(sUrl, sKey) {
    let arr=sUrl.split("?")[1].split("#")[0].split("&");
     let res;
     if(sKey){
         res=[];
         for(let i=0;i<arr.length;i++){
             let [a,b] = arr[i].split("=");
             if(sKey===a){
                 res.push(b)
             }
             
         }
         if(res.length==0){
             return ""
         }
         if(res.length==1){
             return res[0]
         }
         return res
     }else{
         res={}
            for(let i=0;i<arr.length;i++){
             let [a,b]=arr[i].split("=");
             if(res[a]){
                 console.log(b)
                 console.log(res[a])
                 res[a].push(b)
             }else{
                res[a]=[b]
             }
            
         } 
         if(res.lenght==0){
             return res
         }
         return res
         
     }
  }
var a = getUrlParam('http://www.nowcoder.com?key=1&key=2&key=3&key=4&test1=4#hehe'); 
console.log(a)
/* console.log( a.key.join('')) */
